//
//  WBNetWorkManager+extension.swift
//  传智微博
//
//  Created by globalives2 on 2016/11/25.
//  Copyright © 2016年 globalives2. All rights reserved.
//

import Foundation

// MARK: - 封装新浪微博的网络请求方法
extension WBNetWorkManager {
    
    /// 加载微博数据字典数组
    ///
    /// - parameter completion: 完成回调【list: 微博字典数组／是否成功】
    func statusList(completion: @escaping (_ list: [[String: AnyObject]]?,_ isSuccess: Bool)->()) {
        
        // 用 网络工具 加载微博数据
        let urlString = "https://api.weibo.com/2/statuses/home_timeline.json"
        let params = ["access_token": "2.00sirbcDGBZvpC5112c13685TdXyLE"]
        
        request(URLString: urlString, parameters: params as [String : AnyObject]?) { (json, isSuccess) in
            print(json)
            let result = json?["statuses"] as? [[String: AnyObject]]
            
            completion(result,true)
        }
    }
}
